package com.socket.socketTest;

import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * PetServer--bdqnPractice
 *
 * @author: Jovi
 * @createTime: 2017-09-13 15:08
 **/
public class PetServer {

    public static void main(String[] args) throws IOException {

        ServerSocket ss = new ServerSocket(8787);
        Socket socket = ss.accept();

        InputStream is = socket.getInputStream();
        BufferedReader br = new BufferedReader(new InputStreamReader(is));

        String info;
        while ((info = br.readLine()) != null) {
            System.out.println("这里是宠物店，宠物主人输出信息为：" + info);
        }

        OutputStream os = socket.getOutputStream();
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(os));

        String repay = "欢迎光临本店！";
        bw.write(repay);

        bw.close();
        os.close();
        br.close();
        is.close();
        socket.close();
        ss.close();

    }
}
